package reflect;

import java.util.ArrayList;
import java.util.Scanner;

public class ReflectDemo2 {
    public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
        ArrayList list = new ArrayList();
        System.out.println(list);

        Class cls = Class.forName("java.util.ArrayList");
        Object obj = cls.newInstance();
        System.out.println(obj);

        Scanner scan = new Scanner(System.in);
        System.out.println("请输入类名:");
        Class cls2 = Class.forName(scan.nextLine());
        Object obj2 = cls2.newInstance();
        System.out.println(obj2);

    }
}
